import Vue from "vue";
import VueRouter from "vue-router";
import routes from "./routes/index";

Vue.use(VueRouter);

const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  let paths = ['/begin', '/index', '/agreement', '/pricy']
  if((!paths.includes(to.path) && !localStorage.getItem('userinfo')) || (to.path=="/begin" && localStorage.getItem('userinfo'))){
    next('/index');
  }
  next();
})

export default router;
